//
//  NSHomeListCell.m
//  Meboo
//
//  Created by kyo on 2024/3/15.
//

#import "NSHomeListCell.h"
#import "MBWLMTopicImageModel.h"
#import "NSHomeInterestsICell.h"
#import "NSString+Extension.h"
#import "TightnessFlowLayout.h"
#import "NSFlashChatViewController.h"
#import "Meboo-Swift.h"
@interface NSHomeListCell()
<
UICollectionViewDelegate,
UICollectionViewDataSource
>
@property(nonatomic,strong) UIImageView *vipImageView;

@property(nonatomic,strong) UIImageView *topBackImageView;
@property (nonatomic, strong) UIVisualEffectView *effectView;
@property (nonatomic, strong) UIView *topShadowView;

@property(nonatomic,strong) UIImageView *iconImageView;

@property(nonatomic,strong) UILabel *nameLab;
@property(nonatomic,strong) UIButton *tagBtn1;
@property(nonatomic,strong) UIButton *tagBtn2;

@property (nonatomic , strong) UICollectionView *collectionView;

@property(nonatomic,strong) UILabel *titleLab;

@property(nonatomic,strong) UIImageView *marksImageView;


//底部
@property(nonatomic,strong) UIImageView *iconImageView1;
@property(nonatomic,strong) UIImageView *iconImageView2;
@property(nonatomic,strong) UIImageView *iconImageView3;
@property(nonatomic,strong) UIImageView *arrowImageView;

@property(nonatomic,strong) UIButton *likeBtn;
@property(nonatomic,strong) UIButton *fcBtn;

//提示fc
@property(nonatomic,strong) UIImageView *noticeImageView;
@property(nonatomic,strong) UILabel *noticeLab;

//动效
@property(nonatomic,strong) UIView *clickLikeBackView;
@property(nonatomic,strong) NSLottieView *clickLikeAnimationView;

@property(nonatomic,strong) NSLottieView *centerLikeAnimationView;
@property(nonatomic,strong) NSLottieView *fcAnimationView;
@end

@implementation NSHomeListCell
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - Public Metohd

- (void)setModel:(MBWLMTopicModel *)model {
    _model = model;
    
    
    MBWLMTopicImageModel *imageModel = model.images[0];
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:imageModel.imageUrl] placeholderImage:ImageWithName(@"app_defult_image")];
    [self.topBackImageView sd_setImageWithURL:[NSURL URLWithString:imageModel.imageUrl] placeholderImage:ImageWithName(@"app_defult_image")];
    self.nameLab.text = [NSString stringWithFormat:@"%@,%@",model.nickName,model.age];
    
//    NSLog(@"&*&*&*&*&*%@",model.online);
    if ([model.online isEqualToString:@"1"]) {
        self.tagBtn1.hidden = NO;
    } else {
        self.tagBtn1.hidden = YES;
    }
//    if ([model.online isEqualToString:@"1"] && ![model.nearby isEqualToString:@"1"]) {
//        [self.tagBtn1 setTitle:@"Online" forState:0];
//        [self.tagBtn1 setImage:ImageWithName(@"home_list_online") forState:0];
//        self.tagBtn2.hidden = YES;
//        self.tagBtn1.hidden = NO;
//    } else if (![model.online isEqualToString:@"1"] && [model.nearby isEqualToString:@"1"]) {
//        [self.tagBtn1 setTitle:@"Nearby" forState:0];
//        [self.tagBtn1 setImage:ImageWithName(@"home_list_nearby") forState:0];
//        self.tagBtn2.hidden = YES;
//        self.tagBtn1.hidden = NO;
//    } else if (![model.online isEqualToString:@"1"] && ![model.nearby isEqualToString:@"1"]) {
//        self.tagBtn2.hidden = YES;
//        self.tagBtn1.hidden = YES;
//    } else {
//        [self.tagBtn1 setTitle:@"Online" forState:0];
//        [self.tagBtn1 setImage:ImageWithName(@"home_list_online") forState:0];
//        [self.tagBtn2 setTitle:@"Nearby" forState:0];
//        [self.tagBtn2 setImage:ImageWithName(@"home_list_nearby") forState:0];
//        self.tagBtn2.hidden = NO;
//        self.tagBtn1.hidden = NO;
//    }
    self.titleLab.text = model.aboutMe;
    
    //MBWLMTopicImageModel
    if (model.images.count == 1) {
        self.iconImageView1.hidden = YES;
        self.iconImageView2.hidden = YES;
        self.iconImageView3.hidden = YES;
        self.arrowImageView.hidden = YES;
    } else if (model.images.count == 2) {
        self.iconImageView1.hidden = NO;
        self.iconImageView2.hidden = YES;
        self.iconImageView3.hidden = YES;
        self.arrowImageView.hidden = YES;
        [self.iconImageView1 sd_setImageWithURL:[NSURL URLWithString:model.images[1].imageUrl] placeholderImage:ImageWithName(@"app_defult_image")];
    } else if (model.images.count == 3) {
        self.iconImageView1.hidden = NO;
        self.iconImageView2.hidden = NO;
        self.iconImageView3.hidden = YES;
        self.arrowImageView.hidden = YES;
        [self.iconImageView1 sd_setImageWithURL:[NSURL URLWithString:model.images[1].imageUrl] placeholderImage:ImageWithName(@"app_defult_image")];
        [self.iconImageView2 sd_setImageWithURL:[NSURL URLWithString:model.images[2].imageUrl] placeholderImage:ImageWithName(@"app_defult_image")];
    } else {
        self.iconImageView1.hidden = NO;
        self.iconImageView2.hidden = NO;
        self.iconImageView3.hidden = NO;
        self.arrowImageView.hidden = NO;
        [self.iconImageView1 sd_setImageWithURL:[NSURL URLWithString:model.images[1].imageUrl] placeholderImage:ImageWithName(@"app_defult_image")];
        [self.iconImageView2 sd_setImageWithURL:[NSURL URLWithString:model.images[2].imageUrl] placeholderImage:ImageWithName(@"app_defult_image")];
        [self.iconImageView3 sd_setImageWithURL:[NSURL URLWithString:model.images[3].imageUrl] placeholderImage:ImageWithName(@"app_defult_image")];
    }
    
    //userType 2:CM 显示VIP标识 3:M 不显示VIP标识
    if ([model.userType integerValue] == 2) {
        self.vipImageView.hidden = NO;
        self.iconImageView.layer.borderWidth = 2;
    } else {
        self.vipImageView.hidden = YES;
        self.iconImageView.layer.borderWidth = 0;
    }
    
    [self.collectionView reloadData];
}

- (NSString *)getTodayStr {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd"]; // 设置日期格式
    NSDate *today = [NSDate date]; // 获取当前日期
    NSString *dateString = [formatter stringFromDate:today];
    return dateString;
}

- (void)setLikeAnimation:(BOOL)likeAnimation {
    _likeAnimation = likeAnimation;
    __WeakSelf
    if (likeAnimation) {
        self.centerLikeAnimationView.hidden = NO;
        [self.centerLikeAnimationView startAnimationWithCompletionBlock:^(BOOL completed) {
            if (completed) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    weakSelf.centerLikeAnimationView.hidden = YES;
                });
            }
        }];
    } else {
        self.noticeImageView.hidden = YES;
        self.centerLikeAnimationView.hidden = YES;
        [self.centerLikeAnimationView stopAnimation];
    }
}

- (void)setFcAnimation:(BOOL)fcAnimation {
    _fcAnimation = fcAnimation;
    __WeakSelf
    if (fcAnimation) {
        self.noticeImageView.hidden = !fcAnimation;
        self.fcAnimationView.hidden = NO;
        [self.fcAnimationView startAnimationWithCompletionBlock:^(BOOL completed) {
            if (completed) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    weakSelf.fcAnimationView.hidden = YES;
                });
            }
        }];
    } else {
        self.centerLikeAnimationView.hidden = YES;
        [self.centerLikeAnimationView stopAnimation];
    }
}

#pragma mark - Action
- (void)likeAction {
    //点击之前先判断有没有总交互权限  其次判断有没有
    //非会员处理 点击次数问题
    MBUserAccount *account = [MBUserAccount defaultAccount];
    if (![MBUserAccount defaultAccount].isVip) {
        if (account.likeNum < [MBWhoLikeMeDataManager sharedManager].homeLikeNum) {
            //浏览数未达限制
            account.likeNum ++;
            //防止重复点击
            self.currentViewController.view.userInteractionEnabled = NO;
            __WeakSelf
            self.clickLikeBackView.hidden = NO;
            [self.clickLikeAnimationView startAnimationWithCompletionBlock:^(BOOL completed) {
                if (completed) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        if (weakSelf.likeBlock) {
                            weakSelf.likeBlock(NO);
                        }
                    });
                } else {
                    NSLog(@"");
                }
                weakSelf.clickLikeBackView.hidden = YES;
                weakSelf.currentViewController.view.userInteractionEnabled = YES;
            }];
            [MBUserAccount saveAccount:account];
        } else {
            //浏览数达到限制 弹窗 响应block事件
            if (self.likeBlock) {
                self.likeBlock(YES);
            }
            /**
             埋点
             首页 喜欢用户达上限拉起会员订阅 Home_Like_Sub
             */
            [[NSIOApiManager sharedManager] setIOWithEventName:@"Home_Like_Sub"];
        }
    } else {
        //防止重复点击
        self.currentViewController.view.userInteractionEnabled = NO;
        __WeakSelf
        self.clickLikeBackView.hidden = NO;
        [self.clickLikeAnimationView startAnimationWithCompletionBlock:^(BOOL completed) {
            if (completed) {
                dispatch_async(dispatch_get_main_queue(), ^{
                    if (weakSelf.likeBlock) {
                        weakSelf.likeBlock(NO);
                    }
                });
            } else {
                NSLog(@"");
            }
            weakSelf.clickLikeBackView.hidden = YES;
            weakSelf.currentViewController.view.userInteractionEnabled = YES;
        }];
    }

    /**
     埋点
     点击喜欢/like Home_Like
     */
    [[NSIOApiManager sharedManager] setIOWithEventName:@"Home_Like"];
}

- (void)fcAction {
    self.noticeImageView.hidden = YES;
    NSFlashChatViewController *fcViewController = [NSFlashChatViewController new];
    fcViewController.style = HomeCellStyle;
    NSUserInfoModel *model = [NSUserInfoModel new];
    model.nickName = self.model.nickName;
    model.avatarUrl = self.model.avatarUrl;
    model.userCode = self.model.friendUserCode;
    fcViewController.model = model;
    [self.currentViewController.navigationController pushViewController:fcViewController animated:YES];
    /**
     埋点
     点击Flash chat Home_Flash_chat
     */
    [[NSIOApiManager sharedManager] setIOWithEventName:@"Home_Flash_chat"];
}

#pragma mark -- collectionView  delegate datasource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.model.interests.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    NSHomeInterestsICell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"NSHomeInterestsICell" forIndexPath:indexPath];
    MBWLMTopicImageModel *model = self.model.interests[indexPath.row];
    NSString *titleStr = model.interest;
    [cell.titleBtn setTitle:titleStr forState:0];
    return cell;
}

//设置每个section的UIEdgeInsets
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(MBHeightScale(0), MBWidthScale(0), MBHeightScale(0), MBWidthScale(0));
}

//设置列间距
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return MBHeightScale(6);
}

//设置每个item水平间距
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return MBWidthScale(10);
}

//定义每一个cell的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    MBWLMTopicImageModel *model = self.model.interests[indexPath.row];
    NSString *titleStr = model.interest;
    CGSize size = [titleStr sizeWithFont:PDRegularScale(13) maxSize:CGSizeMake(ScreenWidth-MBWidthScale(64), MBHeightScale(24))];
    return CGSizeMake(size.width+MBWidthScale(20), MBHeightScale(24));
}

#pragma mark - UI
- (void)setupUI {
    self.contentView.backgroundColor = HEXS(@"ffffff");
    self.contentView.layer.cornerRadius = MBHeightScale(20);
    self.contentView.layer.masksToBounds = YES;

    [self.contentView addSubview:self.topBackImageView];
    [self.topBackImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(MBHeightScale(79));
        make.left.right.top.equalTo(self.contentView);
    }];
    
    [self.topBackImageView addSubview:self.effectView];
    [self.effectView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.topBackImageView);
    }];
    
    [self.topBackImageView addSubview:self.topShadowView];
    [self.topShadowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.topBackImageView);
    }];
    
    [self.contentView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(MBWidthScale(10));
        make.top.mas_equalTo(MBHeightScale(19));
        make.width.height.mas_equalTo(MBHeightScale(78));
    }];
    
    [self.contentView addSubview:self.vipImageView];
    [self.vipImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(MBWidthScale(9));
        make.top.mas_equalTo(MBHeightScale(17));
        make.width.mas_equalTo(MBWidthScale(31));
        make.height.mas_equalTo(MBHeightScale(23));
    }];
    
    [self.contentView addSubview:self.nameLab];
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImageView);
        make.left.equalTo(self.iconImageView.mas_right).offset(MBWidthScale(18));
        make.right.mas_equalTo(MBWidthScale(-9));
    }];
    
    [self.contentView addSubview:self.tagBtn1];
    [self.tagBtn1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameLab.mas_bottom).offset(MBHeightScale(5));
        make.left.equalTo(self.nameLab);
    }];
    
    [self.contentView addSubview:self.tagBtn2];
    [self.tagBtn2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.tagBtn1);
        make.left.equalTo(self.tagBtn1.mas_right).offset(MBWidthScale(12));
    }];
    
    [self.contentView addSubview:self.collectionView];
    [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topBackImageView.mas_bottom).offset(MBHeightScale(33));
        make.left.mas_equalTo(MBWidthScale(12));
        make.right.mas_equalTo(MBWidthScale(-12));
        make.height.mas_equalTo(MBHeightScale(24));
    }];
    
    [self.contentView addSubview:self.marksImageView];
    [self.marksImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.topBackImageView.mas_bottom).offset(MBHeightScale(66));
        make.left.mas_equalTo(MBWidthScale(12));
        make.width.mas_equalTo(MBWidthScale(11));
        make.height.mas_equalTo(MBWidthScale(11)/11*8);
    }];
    
    [self.contentView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.marksImageView.mas_bottom).offset(MBHeightScale(3));
        make.left.mas_equalTo(MBWidthScale(12));
        make.right.mas_equalTo(MBWidthScale(-12));
    }];
    
    [self.contentView addSubview:self.iconImageView1];
    [self.iconImageView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(MBHeightScale(48));
        make.bottom.mas_equalTo(MBHeightScale(-20));
        make.left.mas_equalTo(MBWidthScale(12));
    }];
    
    [self.contentView addSubview:self.iconImageView2];
    [self.iconImageView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(MBHeightScale(48));
        make.bottom.mas_equalTo(MBHeightScale(-20));
        make.left.equalTo(self.iconImageView1.mas_right).offset(MBWidthScale(6));
    }];
    
    [self.contentView addSubview:self.iconImageView3];
    [self.iconImageView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(MBHeightScale(48));
        make.bottom.mas_equalTo(MBHeightScale(-20));
        make.left.equalTo(self.iconImageView2.mas_right).offset(MBWidthScale(6));
    }];
    
    [self.contentView addSubview:self.arrowImageView];
    [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(MBHeightScale(16));
        make.bottom.mas_equalTo(MBHeightScale(-20));
        make.left.equalTo(self.iconImageView3.mas_right).offset(MBWidthScale(10));
    }];
    
    [self.contentView addSubview:self.fcBtn];
    [self.fcBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(MBHeightScale(36));
        make.bottom.mas_equalTo(MBHeightScale(-20));
        make.right.mas_equalTo(MBWidthScale(-14));
    }];
    
    [self.contentView addSubview:self.likeBtn];
    [self.likeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(MBHeightScale(36));
        make.bottom.mas_equalTo(MBHeightScale(-20));
        make.right.equalTo(self.fcBtn.mas_left).mas_equalTo(MBWidthScale(-10));
    }];
    
    [self.contentView addSubview:self.noticeImageView];
    [self.noticeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(MBHeightScale(40));
        make.bottom.equalTo(self.fcBtn.mas_top).offset(MBHeightScale(-3));
        make.right.equalTo(self.fcBtn);
    }];
    
    [self.noticeImageView addSubview:self.noticeLab];
    [self.noticeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(MBHeightScale(-3));
        make.left.mas_equalTo(MBWidthScale(11));
        make.right.mas_equalTo(MBWidthScale(-11));
    }];
    
    [self.contentView addSubview:self.clickLikeBackView];
    [self.clickLikeBackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    
    [self.clickLikeBackView addSubview:self.clickLikeAnimationView];
    [self.clickLikeAnimationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.clickLikeBackView);
        make.width.height.mas_equalTo(MBHeightScale(50));
    }];
    
    [self.likeBtn addSubview:self.centerLikeAnimationView];
    [self.centerLikeAnimationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.likeBtn);
        make.bottom.equalTo(self.likeBtn).offset(-2);
        make.width.height.mas_equalTo(MBHeightScale(50));
    }];
    
    [self.fcBtn addSubview:self.fcAnimationView];
    [self.fcAnimationView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.fcBtn);
        make.width.height.mas_equalTo(MBHeightScale(36));
    }];
    
    
    
    [self.topBackImageView layoutIfNeeded];
    UIBezierPath *maskPath;
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskPath = [UIBezierPath bezierPathWithRoundedRect:self.topBackImageView.bounds byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight) cornerRadii:CGSizeMake(MBHeightScale(15),MBHeightScale(15))];//圆角大小
    maskLayer.frame = self.topBackImageView.bounds;
    maskLayer.path = maskPath.CGPath;
    self.topBackImageView.layer.mask = maskLayer;
}

#pragma mark - Setter && Getter

- (UIImageView *)vipImageView {
    if (!_vipImageView) {
        _vipImageView = [UIImageView new];
        _vipImageView.image = ImageWithName(@"home_list_vip_icon");
//        _vipImageView.hidden = YES;
    }
    return _vipImageView;
}

- (UIImageView *)iconImageView {
    if (!_iconImageView) {
        _iconImageView = [UIImageView new];
        _iconImageView.image = ImageWithName(@"flower_defult");
        _iconImageView.contentMode = UIViewContentModeScaleAspectFill;
        _iconImageView.layer.cornerRadius = MBHeightScale(78/2);
        _iconImageView.layer.borderColor = HEXS(@"A84FFF").CGColor;
        _iconImageView.layer.borderWidth = 2;
        _iconImageView.layer.masksToBounds = YES;
    }
    return _iconImageView;
}

- (UIImageView *)topBackImageView {
    if (!_topBackImageView) {
        _topBackImageView = [UIImageView new];
        _topBackImageView.contentMode = UIViewContentModeScaleAspectFill;
        _topBackImageView.image = ImageWithName(@"fashion_cell_topback");
    }
    return _topBackImageView;
}


- (UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [UILabel new];
        _titleLab.font = MBHelFontSizeScale(15);
        _titleLab.numberOfLines = 2;
        _titleLab.textColor = HEXS(@"666666");
    }
    return _titleLab;
}

- (UIButton *)tagBtn1 {
    if (!_tagBtn1) {
        _tagBtn1 = [UIButton leftimageAndRighttitlePatternWithImage:@"home_list_online" AndMargin:4 AndTitle:@"Online" AndTitleFont:MBHelFontSizeScale(12) AndTitleColor:HEXS(@"ffffff")];
    }
    return _tagBtn1;
}

- (UIButton *)tagBtn2 {
    if (!_tagBtn2) {
        _tagBtn2 = [UIButton leftimageAndRighttitlePatternWithImage:@"home_list_nearby" AndMargin:4 AndTitle:@"Nearby" AndTitleFont:MBHelFontSizeScale(12) AndTitleColor:HEXS(@"ffffff")];
        _tagBtn2.hidden = YES;
    }
    return _tagBtn2;
}

- (UILabel *)nameLab {
    if (!_nameLab) {
        _nameLab = [UILabel new];
        _nameLab.font = MBHelBoldFontSizeScale(16);
        _nameLab.textColor = UIColor.whiteColor;
    }
    return _nameLab;
}

- (UIImageView *)marksImageView {
    if (!_marksImageView) {
        _marksImageView = [UIImageView new];
        _marksImageView.image = ImageWithName(@"home_list_marks_icon");
    }
    return _marksImageView;
}

- (UICollectionView *)collectionView {
    if (!_collectionView) {
        TightnessFlowLayout *flowLayout = [[TightnessFlowLayout alloc] init];
        flowLayout.minimumInteritemSpacing = 0;
        flowLayout.minimumLineSpacing = 0;
        _collectionView = [[UICollectionView alloc] initWithFrame:self.contentView.bounds collectionViewLayout:flowLayout];
        _collectionView.backgroundColor = UIColor.clearColor;
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        _collectionView.scrollEnabled = NO;
        _collectionView.showsVerticalScrollIndicator = NO;
        _collectionView.showsHorizontalScrollIndicator = NO;
        [_collectionView registerClass:[NSHomeInterestsICell class] forCellWithReuseIdentifier:@"NSHomeInterestsICell"];
    }
    return _collectionView;
}

//底部
- (UIImageView *)iconImageView1 {
    if (!_iconImageView1) {
        _iconImageView1 = [UIImageView new];
        _iconImageView1.image = ImageWithName(@"flower_defult");
        _iconImageView1.contentMode = UIViewContentModeScaleAspectFill;
        _iconImageView1.layer.cornerRadius = MBHeightScale(6);
        _iconImageView1.layer.masksToBounds = YES;
    }
    return _iconImageView1;
}

- (UIImageView *)iconImageView2 {
    if (!_iconImageView2) {
        _iconImageView2 = [UIImageView new];
        _iconImageView2.image = ImageWithName(@"flower_defult");
        _iconImageView2.contentMode = UIViewContentModeScaleAspectFill;
        _iconImageView2.layer.cornerRadius = MBHeightScale(6);
        _iconImageView2.layer.masksToBounds = YES;
    }
    return _iconImageView2;
}

- (UIImageView *)iconImageView3 {
    if (!_iconImageView3) {
        _iconImageView3 = [UIImageView new];
        _iconImageView3.image = ImageWithName(@"flower_defult");
        _iconImageView3.contentMode = UIViewContentModeScaleAspectFill;
        _iconImageView3.layer.cornerRadius = MBHeightScale(6);
        _iconImageView3.layer.masksToBounds = YES;
    }
    return _iconImageView3;
}

- (UIImageView *)arrowImageView {
    if (!_arrowImageView) {
        _arrowImageView = [UIImageView new];
        _arrowImageView.image = ImageWithName(@"home_list_arrow_icon");
    }
    return _arrowImageView;
}

- (UIButton *)likeBtn {
    if (!_likeBtn) {
        _likeBtn = [UIButton new];
        [_likeBtn setYXEnlargeEdgeWithTop:15 right:3 bottom:15 left:15];
        [_likeBtn setImage:ImageWithName(@"home_list_like_icon") forState:0];
        _likeBtn.layer.cornerRadius = MBHeightScale(18);
        [_likeBtn addTarget:self action:@selector(likeAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _likeBtn;
}

- (UIButton *)fcBtn {
    if (!_fcBtn) {
        _fcBtn = [UIButton new];
        [_fcBtn setYXEnlargeEdgeWithTop:15 right:15 bottom:15 left:3];
        [_fcBtn setImage:ImageWithName(@"home_list_fc_icon") forState:0];
        _fcBtn.layer.cornerRadius = MBHeightScale(18);
        [_fcBtn addTarget:self action:@selector(fcAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _fcBtn;
}

- (UIImageView *)noticeImageView {
    if (!_noticeImageView) {
        _noticeImageView = [UIImageView new];
        _noticeImageView.image = ImageWithName(@"home_list_fcnotice_icon");
        _noticeImageView.hidden = YES;
    }
    return _noticeImageView;
}

- (UILabel *)noticeLab {
    if (!_noticeLab) {
        _noticeLab = [UILabel new];
        _noticeLab.font = PDRegularScale(15);
        _noticeLab.text = @"Free to talk,Chat without waiting!!!";
        _noticeLab.textColor = UIColor.whiteColor;
    }
    return _noticeLab;
}

//lottie
- (UIView *)clickLikeBackView {
    if (!_clickLikeBackView) {
        _clickLikeBackView = [UIView new];
        _clickLikeBackView.hidden = YES;
        _clickLikeBackView.layer.cornerRadius = MBHeightScale(20);
        _clickLikeBackView.backgroundColor = [UIColor colorWithRed:0 / 255.0 green:0 / 255.0 blue:0 / 255.0 alpha:0.5];
    }
    return _clickLikeBackView;
}

- (NSLottieView *)clickLikeAnimationView {
    if (!_clickLikeAnimationView) {
        _clickLikeAnimationView = [NSLottieView new];
        [_clickLikeAnimationView defultSetWithName:@"likeClick.json" loop:NO];
    }
    return _clickLikeAnimationView;
}

- (NSLottieView *)centerLikeAnimationView {
    if (!_centerLikeAnimationView) {
        _centerLikeAnimationView = [NSLottieView new];
        _centerLikeAnimationView.hidden = YES;
        _centerLikeAnimationView.userInteractionEnabled = NO;
        [_centerLikeAnimationView defultSetWithName:@"cardInCenter.json" loop:NO];
    }
    return _centerLikeAnimationView;
}

- (NSLottieView *)fcAnimationView {
    if (!_fcAnimationView) {
        _fcAnimationView = [NSLottieView new];
        _fcAnimationView.hidden = YES;
        _fcAnimationView.userInteractionEnabled = NO;
        [_fcAnimationView defultSetWithName:@"fcClick.json" loop:NO];
    }
    return _fcAnimationView;
}

- (UIView *)topShadowView {
    if (!_topShadowView) {
        _topShadowView = [UIView new];
        //渐变色 设置开始和结束位置(设置渐变的方向)
        CAGradientLayer *gradient = [CAGradientLayer layer];
        gradient.startPoint = CGPointMake(0, 0);
        gradient.endPoint = CGPointMake(0, 1);
        gradient.locations = @[@(0.0),@(1.0f)];
        gradient.frame =CGRectMake(0,0,ScreenWidth-MBWidthScale(40),MBHeightScale(79));
        gradient.colors = [NSArray arrayWithObjects:(id)[UIColor colorWithRed:0 / 255.0 green:0 / 255.0 blue:0 / 255.0 alpha:0.1].CGColor,(id)[UIColor colorWithRed:0 / 255.0 green:0 / 255.0 blue:0 / 255.0 alpha:0].CGColor,nil];
        [_topShadowView.layer insertSublayer:gradient atIndex:0];
    }
    return _topShadowView;
}

- (UIVisualEffectView *)effectView {
    if (!_effectView) {
        UIBlurEffect *blurEffrct = [UIBlurEffect effectWithStyle:UIBlurEffectStyleSystemUltraThinMaterialDark];
        _effectView = [[UIVisualEffectView alloc]initWithEffect:blurEffrct];
//        _effectView.backgroundColor = [UIColor colorWithRed:0 / 255.0 green:0 / 255.0 blue:0 / 255.0 alpha:0.5];
        _effectView.alpha = 0.98;
//        _effectView.hidden = YES;
    }
    return _effectView;
}

@end
